package com.fzd.code.encrpty;

import lombok.extern.slf4j.Slf4j;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

@Slf4j
public class EncrptyUtil {

	public static String md5(String str) throws NoSuchAlgorithmException{
		MessageDigest md5 = MessageDigest.getInstance("MD5");
		byte[] bytes = md5.digest(str.getBytes());
		StringBuffer stringBuffer = new StringBuffer();
		for (byte b : bytes){
			int bt = b&0xff;
			if (bt < 16){
				stringBuffer.append(0);
			}
			stringBuffer.append(Integer.toHexString(bt));
		}

		return stringBuffer.toString();
	}

}

